using System.Runtime.Serialization;
using Crm2011.Framework.Core;



namespace ScriptEase
{
    [DataContract]
    public class WebResourceFileMapping
    {
        public WebResourceFileMapping(WebResource webResource, string fileName, bool enabled)
        {
            this.WebResourceType = webResource.GetTypeValue();
            this.WebResourceName = webResource.Name;
            this.FileName = fileName;
            this.Enabled = enabled;
        }



        [OnDeserializing]
        private void beforeDeserialization(StreamingContext ctx)
        {
            setDefaults();
        }



        private void setDefaults()
        {
            // for properties not in the loaded XML
            this.Enabled = true;
        }



        /// <summary>
        /// Gets the relative path of the script file.
        /// </summary>
        [DataMember(Order = 10)]
        public bool Enabled { get; set; }


        [DataMember(Order = 10, EmitDefaultValue = false)]
        public string FileName { get; set; }


        [DataMember(Order = 20)]
        public string WebResourceName { get; private set; }


        [DataMember(Order = 30)]
        public int WebResourceType { get; private set; }
    }
}